<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/login.css"/>
    <link rel="stylesheet" href="css/iconfont.css" />
    <link rel="stylesheet" href="css/layer.css" />
	<link rel="icon" href="images/favicon.png">
</head>
<style type="text/css">
	html,body{
		background:#fff;
	}
</style>
<body id="test_pasd">
	<div class="btn_back iconfont icon-fanhui">
		<a class="back_a">
			<img src="images/back.png"/>
		</a>
	</div>
	<div class="pasd_bg" id="test_bg">
		<div class="pasd_tit">修改用户信息</div>
		<dl class="inpt_dl">
			<dt class="inpt_dt">
				<img src="images/姓名.png"/>
			</dt>
			<dd class="inpt_dd">
				<input type="text" placeholder="您的姓名" class="inpt_all phone" id="userName"/>
				<span class="span_img" id="x_div">
					<img src="images/x.png" style="width:67%;margin:6px 0 0 5px;"/>
				</span>
			</dd>
		</dl>
		<dl class="inpt_dl">
			<dt class="inpt_dt">
				<img src="images/微信号.png"/>
			</dt>
			<dd class="inpt_dd">
				<input type="text" placeholder="您的微信号" class="inpt_all phone" id="weChat"/>
				<span class="span_img" id="x_div">
					<img src="images/x.png" style="width:67%;margin:6px 0 0 5px;"/>
				</span>
			</dd>
		</dl>

		<button class="btn_pasd">保存</button>
	</div>
</body>
<script type="text/javascript" src="js/jquery.js" ></script>
<script type="text/javascript" src="js/layer.js" ></script>
<script type="text/javascript">
	autodivheight();
	function autodivheight() { //函数：获取尺寸  
		//获取浏览器窗口高度  
		var winHeight = 0;
		if(window.innerHeight) {
			winHeight = window.innerHeight;
		} else if((document.body) && (document.body.clientHeight)) {
			winHeight = document.body.clientHeight;
			//通过深入Document内部对body进行检测，获取浏览器窗口高度  
		}
		if(document.documentElement && document.documentElement.clientHeight) {
			winHeight = document.documentElement.clientHeight;
			//DIV高度为浏览器窗口的高度  
			document.getElementById("test_pasd").style.height = winHeight + "px";
		}
	}
	window.onresize = autodivheight; //浏览器窗口发生变化时同时变化DIV高度  
	//背景高度固定
	height_bg();
	function height_bg() { //函数：获取尺寸  
		//获取浏览器窗口高度  
		var winHeight = 0;
		if(window.innerHeight) {
			winHeight = window.innerHeight;
		} else if((document.body) && (document.body.clientHeight)) {
			winHeight = document.body.clientHeight;
			//通过深入Document内部对body进行检测，获取浏览器窗口高度  
		}
		if(document.documentElement && document.documentElement.clientHeight) {
			winHeight = document.documentElement.clientHeight;
			//DIV高度为浏览器窗口的高度  
			document.getElementById("test_bg").style.height = winHeight - 75 + "px";
		}
	}
	window.onresize = height_bg; //浏览器窗口发生变化时同时变化DIV高度  
    //返回上一级
    $(".back_a").click(function(){
        window.location.href ="/index";
    })
	//消除手机号
	$("#pass-phone").on({
	    focus:function() {
	      $("#x_div").show();
	    },
	    blur:function() {
	      setTimeout(function(){
	        $("#x_div").hide();
	      },0)
	    }
	})
	$("#x_div").click(function(){ 
		$("#pass-phone").val("")
	})

	$(".btn_pasd").click(function(){
		if($("#weChat").val() == ""){
            layer.msg('请输入商家微信号', {
                time:2000
            });
		}else if($("#userName").val() == ""){
            layer.msg('请输入商家姓名', {
                time:2000
            });
		}else{
            var registerInfo={
                "weChat":"",//商家微信号
                "userName":"",//商家姓名
            };
            registerInfo.weChat = $('#weChat').val();
            registerInfo.userName = $('#userName').val();
            var storage=window.localStorage;
            var token=storage.token;
            if(token==undefined){
                window.location.href = "/"
            }
            $.ajax({
                type: "POST",
                url: "/users/updateProfile?token="+token,
                contentType: "application/json;charset=UTF-8",
                data:JSON.stringify(registerInfo),
                dataType: "json",
                success: function (data) {
                    if (data.code && data.code==='success') {
                        layer.msg(data.message);
                        setTimeout(function() { window.location.href = "/updateProfile"; }, 2000 );
                    } else {
                        layer.msg(data.message+"，请重试",{icon:2,time:1000});
                    }
                },
                error: function (data) {
                    if(data.code==undefined){
                        layer.msg("登录失效",{icon:2,time:1000});
                        window.location.href ="/";
                    }
                    layer.msg(data.message,{icon:2,time:1000});
                }
            });
		}
	})
</script>
</html>